package com.feicheng.service;

import com.feicheng.common.constant.Constant;
import com.feicheng.common.wx.pay.WxPayBean;
import com.feicheng.service.impl.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

@Component
public class ServiceBeanManager {

    @Autowired
    FAdminPasswordLoginServiceImpl fAdminPasswordLoginServiceImpl;

    @Autowired
    FShopPasswordLoginServiceImpl fShopPasswordLoginServiceImpl;

    @Autowired
    FTelMessageLoginServiceImpl fTelMessageLoginServiceImpl;

    @Autowired
    FAdminSystemServiceImpl fAdminSystemServiceImpl;

    @Autowired
    FShopSystemServiceImpl fShopSystemServiceImpl;

    @Autowired
    FClientWxCodeLoginServiceImpl fClientWxCodeLoginServiceImpl;
    
    @Autowired
    FClientWxAppLoginServiceImpl fClientWxAppLoginServiceImpl;

    private Map<String, IFSystemService> systemServiceMap = new HashMap<String, IFSystemService>();

    private Map<String, IFLoginService> systemLoginServiceMap = new HashMap<String, IFLoginService>();

    private Map<String, IFLoginService> shopLoginServiceMap = new HashMap<String, IFLoginService>();

    private Map<String, IFLoginService> clientLoginServiceMap = new HashMap<String, IFLoginService>();



    private Map<String, IFPayService> payServiceMap = new HashMap<String, IFPayService>();
    

    @Resource(name="wx-pay-service")
    IFPayService wxPayService;

    @Bean(name="pay-service")
    public Map<String, IFPayService> getPayServiceMap() {
        payServiceMap.put(Constant.PAY_TYPE.WX, wxPayService);
        return payServiceMap;
    }

    @Bean(name="system-service")
    public Map<String, IFSystemService> getSystemServiceBean() {
        systemServiceMap.put(Constant.MODEL_NAME.MAIN, fAdminSystemServiceImpl);
        systemServiceMap.put(Constant.MODEL_NAME.SHOP, fShopSystemServiceImpl);
        return systemServiceMap;
    }

    @Bean(name="main-system-login")
    public Map<String, IFLoginService> getSystemLoginServiceBean() {
        systemLoginServiceMap.put(Constant.LOGIN_TYPE.AP, fAdminPasswordLoginServiceImpl);
        systemLoginServiceMap.put(Constant.LOGIN_TYPE.TM, fTelMessageLoginServiceImpl);
        return systemLoginServiceMap;
    }

    @Bean(name="shop-system-login")
    public Map<String, IFLoginService> getShopSystemLoginServiceBean() {
        shopLoginServiceMap.put(Constant.LOGIN_TYPE.AP, fShopPasswordLoginServiceImpl);
        return shopLoginServiceMap;
    }

    @Bean(name="client-login")
    public Map<String, IFLoginService> getClientLoginServiceBean() {
        clientLoginServiceMap.put(Constant.LOGIN_TYPE.WX_CODE, fClientWxCodeLoginServiceImpl);
        clientLoginServiceMap.put(Constant.LOGIN_TYPE.WX_APP, fClientWxAppLoginServiceImpl);
        
        
        return clientLoginServiceMap;
    }


}
